package com.springCloud.demo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Objects;

/**
 * @ClassName User
 * @Author 1628994918qq.com
 * @Date 2023/3/30 22:22
 */
public class User implements Serializable {
    private Long userId;

    private String userName;

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return Objects.equals(userId, user.userId) && Objects.equals(userName, user.userName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, userName);
    }

    public static void main(String[] args) {
        HashMap<User,String> map = new HashMap<>();
        map.put(new User(),"12345678");
        map.put(new User(),"87654321");
        System.out.println(map);

        if(Objects.equals(123,23)){
            System.out.println("相等");
        }else {
            System.out.println("不相等");
        }
    }
}
